<template>
  <div class="goods-list">
    <!-- <router-link class="goods-item" v-for="item in getGoodsList" :key="item.id" :to="'/home/goodsinfo/'+item.id" tag="div">
      <img :src="item.img_url" alt>
      <h1 class="title">{{item.title}}</h1>
      <div class="info">
        <p class="price">
          <span class="now">￥{{item.sell_price}}</span>
          <span class="old">￥{{item.market_price}}</span>
        </p>
        <p class="sell">
          <span>热卖中</span>
          <span>剩余{{stock_quantity}}件</span>
        </p>
      </div>
    </router-link> -->
    <!-- <router-link class="goods-item" to="/home/goodsinfo/">
      <img
        src="https://img.alicdn.com/imgextra/i2/2088045547/O1CN01ofFY6Y1qqZTBx9Ym8_!!2088045547.jpg_430x430q90.jpg"
        alt
      >
      <h1 class="title">12期免息/可减400+顺丰急速发】Huawei/华为 nova 3手机官方旗舰店官网易烊千玺星耀版双4G全网通nova4青春版</h1>
      <div class="info">
        <p class="price">
          <span class="now">￥2199</span>
          <span class="old">￥2399</span>
        </p>
        <p class="sell">
          <span>热卖中</span>
          <span>剩余60件</span>
        </p>
      </div>
    </router-link> -->
    <!-- <div class="goods-item" to="/home/goodsinfo/" @click="getDetail(item.id)"> -->
    <div class="goods-item" to="/home/goodsinfo/" @click="getDetail">
      <img
        src="https://img.alicdn.com/imgextra/i2/2088045547/O1CN01ofFY6Y1qqZTBx9Ym8_!!2088045547.jpg_430x430q90.jpg"
        alt
      >
      <h1 class="title">12期免息/可减400+顺丰急速发】Huawei/华为 nova 3手机官方旗舰店官网易烊千玺星耀版双4G全网通nova4青春版</h1>
      <div class="info">
        <p class="price">
          <span class="now">￥2199</span>
          <span class="old">￥2399</span>
        </p>
        <p class="sell">
          <span>热卖中</span>
          <span>剩余60件</span>
        </p>
      </div>
    </div>
    <div class="goods-item">
      <img
        src="https://img.alicdn.com/imgextra/i2/1684634320/O1CN01jdKeFg1hmbUpRJTzA_!!0-item_pic.jpg_430x430q90.jpg"
        alt
      >
      <h1 class="title">12期免息/可减400+顺丰急速发】Huawei/华为 nova 3手机官方旗舰店官网易烊千玺星耀版双4G全网通nova4青春版</h1>
      <div class="info">
        <p class="price">
          <span class="now">￥2199</span>
          <span class="old">￥2399</span>
        </p>
        <p class="sell">
          <span>热卖中</span>
          <span>剩余60件</span>
        </p>
      </div>
    </div>
    <div class="goods-item">
      <img
        src="https://img.alicdn.com/imgextra/i4/2024314280/O1CN01fVYjVp1hUHeZr8YqI_!!0-item_pic.jpg_430x430q90.jpg"
        alt
      >
      <h1 class="title">12期免息/可减400+顺丰急速发】Huawei/华为 nova 3手机官方旗舰店官网易烊千玺星耀版双4G全网通nova4青春版</h1>
      <div class="info">
        <p class="price">
          <span class="now">￥2199</span>
          <span class="old">￥2399</span>
        </p>
        <p class="sell">
          <span>热卖中</span>
          <span>剩余60件</span>
        </p>
      </div>
    </div>
    <mt-button type="danger" size="large" @click="getMore">加载更多</mt-button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pageindex: 1,
      goodsList: []
    };
  },
  created() {
    this.getGoodsList();
  },
  methods: {
    getGoodsList() {
      this.$http
        .get("api/getgoods?pageindex=" + this.pageindex)
        .then(result => {
          if (result.body.status === 0) {
            this.goodsList = this.goodsList.concat(result.body.message)
          }
        });
    },
    getMore(){
        this.pageindex++
        this.getGoodsList()
    },
    // getDetail(id){
    //   console.log(this)
    //   this.$router.push({name:'goodslist',parmas:{id}})
    // }
     getDetail(){
     this.$router.push({name:'goodsinfo'})
    }
  }
};
</script>
<style lang="scss" scoped>
.goods-list {
  display: flex;
  flex-wrap: wrap;
  padding: 7px;
  justify-content: space-between;
  .goods-item {
    width: 49%;
    border: 1px solid #ccc;
    box-shadow: 0 0 8px #ccc;
    margin: 4px 0;
    padding: 2px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 293px;
    img {
      width: 100%;
    }
    .title {
      font-size: 11px;
      line-height: 13px;
      text-indent: 2em;
      letter-spacing: 2px;
      color: #616060;
    }
  }
  .info {
    background-color: #eee;
    p {
      margin: 0;
      padding: 5px;
    }
    .price {
      .now {
        color: red;
        font-weight: 700;
        font-size: 16px;
      }
      .old {
        text-decoration: line-through;
        font-size: 12px;
        margin-left: 10px;
      }
    }
    .sell {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
    }
  }
}
</style>
